package com.wswy.wzcx.model.resp;

import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.google.gson.annotations.SerializedName;
import com.wswy.wzcx.model.TrafficViolationInfo;
import com.wswy.wzcx.model.license.UserCarInfo;
import java.util.List;

public class QueryResult implements android.os.Parcelable {

  public int errorCode;

  public String errorMsg;

  public List<TrafficViolationInfo> fineList;

  public UserCarInfo userCarInfo;

  //显示罚单已提交的提示还显示的提示
  public boolean showTips;

  //查询结果来自本地缓存
  public boolean fromCache = false;

  //查询结果是本地生成的数据，不缓存
  public boolean noCache = false;

  public boolean isSuccess(){
    return errorCode == 0;
  }

  public QueryResult() {
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(this.errorCode);
    dest.writeString(this.errorMsg);
    dest.writeTypedList(this.fineList);
    dest.writeParcelable(this.userCarInfo, flags);
    dest.writeByte(this.fromCache ? (byte) 1 : (byte) 0);
    dest.writeByte(this.noCache ? (byte) 1 : (byte) 0);
  }

  protected QueryResult(Parcel in) {
    this.errorCode = in.readInt();
    this.errorMsg = in.readString();
    this.fineList = in.createTypedArrayList(TrafficViolationInfo.CREATOR);
    this.userCarInfo = in.readParcelable(UserCarInfo.class.getClassLoader());
    this.fromCache = in.readByte() != 0;
    this.noCache = in.readByte() != 0;
  }

  public static final Creator<QueryResult> CREATOR = new Creator<QueryResult>() {
    @Override
    public QueryResult createFromParcel(Parcel source) {
      return new QueryResult(source);
    }

    @Override
    public QueryResult[] newArray(int size) {
      return new QueryResult[size];
    }
  };
}
